home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / io / ObjectStreamConstants.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  5.2 KB  |  195 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)ObjectStreamConstants.java    1.22 98/07/10
  3.  *
  4.  * Copyright 1996-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.io;
  16.  
  17. /**
  18.  * Constants written into the Object Serialization Stream. 
  19.  *
  20.  * @author  unascribed
  21.  * @version 1.22, 07/10/98
  22.  * @since JDK 1.1
  23.  */
  24. public interface ObjectStreamConstants {
  25.     final static short STREAM_MAGIC = (short)0xaced;
  26.     final static short STREAM_VERSION = 5;
  27.  
  28.     /* Each item in the stream is preceded by a tag
  29.      */
  30.  
  31.     /** 
  32.      * First tag value.
  33.      */
  34.     final static byte TC_BASE = 0x70;
  35.     /**
  36.      * Null object reference.
  37.      */
  38.     final static byte TC_NULL =     (byte)0x70;
  39.  
  40.     /**
  41.      * Reference to an object already written into the stream.
  42.      */
  43.     final static byte TC_REFERENCE =    (byte)0x71;
  44.  
  45.     /**
  46.      * new Class Descriptor.
  47.      */
  48.     final static byte TC_CLASSDESC =     (byte)0x72;
  49.  
  50.     /**
  51.      * new Object
  52.      */
  53.     final static byte TC_OBJECT =     (byte)0x73;
  54.  
  55.     /** 
  56.      * new String
  57.      */
  58.     final static byte TC_STRING =     (byte)0x74;
  59.  
  60.     /**
  61.      * new Array
  62.      */
  63.     final static byte TC_ARRAY =     (byte)0x75;
  64.  
  65.     /**
  66.      * Reference to Class.
  67.      */
  68.     final static byte TC_CLASS =     (byte)0x76;
  69.  
  70.     /**
  71.      * Block of optional data. Byte following tag indicates number
  72.      * of bytes in this block data.
  73.      */
  74.     final static byte TC_BLOCKDATA =     (byte)0x77;
  75.  
  76.     /** 
  77.      * End of optional block data blocks for an object.
  78.      */
  79.     final static byte TC_ENDBLOCKDATA =    (byte)0x78;
  80.  
  81.     /**
  82.      * Reset stream context. All handles written into stream are reset.
  83.      */
  84.     final static byte TC_RESET =     (byte)0x79;
  85.     
  86.     /**
  87.      * long Block data. The long following the tag indicates the
  88.      * number of bytes in this block data.
  89.      */
  90.     final static byte TC_BLOCKDATALONG= (byte)0x7A;
  91.     
  92.     /**
  93.      * Exception during write. 
  94.      */
  95.     final static byte TC_EXCEPTION =     (byte)0x7B;
  96.  
  97.     /** 
  98.      * Last tag value.
  99.      */
  100.     final static byte TC_MAX =         (byte)0x7B;
  101.  
  102.     /**
  103.      * First wire handle to be assigned. 
  104.      */
  105.     final static int baseWireHandle = 0x7e0000;
  106.  
  107.  
  108.     /******************************************************/
  109.     /* Bit masks for ObjectStreamClass flag.*/
  110.  
  111.     /** 
  112.      * Bit mask for ObjectStreamClass flag. Indicates a Serializable class 
  113.      * defines its own writeObject method.
  114.      */
  115.     final static byte SC_WRITE_METHOD = 0x01;
  116.  
  117.     /**
  118.      * Bit mask for ObejctStreamClass flag. Indicates Externalizable data 
  119.      * written in Block Data mode.
  120.      * Added for PROTOCOL_VERSION_2.
  121.      *
  122.      * @see #PROTOCOL_VERSION_2
  123.      * @since JDK 1.2
  124.      */
  125.     final static byte SC_BLOCK_DATA = 0x08;  
  126.  
  127.     /**
  128.      * Bit mask for ObjectStreamClass flag. Indicates class is Serializable.
  129.      */
  130.     final static byte SC_SERIALIZABLE = 0x02;
  131.  
  132.     /**
  133.      * Bit mask for ObjectStreamClass flag. Indicates class is Externalizable.
  134.      */
  135.     final static byte SC_EXTERNALIZABLE = 0x04;
  136.  
  137.     
  138.     /* *******************************************************************/
  139.     /* Security permissions */
  140.  
  141.     /**
  142.      * Enable substitution of one object for another during 
  143.      * serialization/deserialization.
  144.      *
  145.      * @see java.io.ObjectOutputStream#enableReplaceObject(boolean)
  146.      * @see java.io.ObjectInputStream#enableResolveObject(boolean)
  147.      * @since JDK 1.2
  148.      */
  149.     final static SerializablePermission SUBSTITUTION_PERMISSION =
  150.                            new SerializablePermission("enableSubstitution");
  151.  
  152.     /**
  153.      * Enable overriding of readObject and writeObject.
  154.      *
  155.      * @see java.io.ObjectOutputStream#writeObjectOverride(Object)
  156.      * @see java.io.ObjectInputStream#readObjectOverride()
  157.      * @since JDK 1.2
  158.      */
  159.     final static SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION =
  160.                     new SerializablePermission("enableSubclassImplementation");
  161.    /**
  162.     * A Stream Protocol Version. <p>
  163.     * 
  164.     * All externalizable data is written in JDK 1.1 external data 
  165.     * format after calling this method. This version is needed to write 
  166.     * streams containing Externalizable data that can be read by 
  167.     * pre-JDK 1.1.6 JVMs.
  168.     *
  169.     * @see java.io.ObjectOutputStream#useProtocolVersion(int)
  170.     * @since JDK 1.2
  171.     */
  172.     public final static int PROTOCOL_VERSION_1 = 1;
  173.  
  174.     
  175.    /**
  176.     * A Stream Protocol Version. <p>
  177.     * 
  178.     * This protocol is written by JVM 1.2.
  179.     *
  180.     * Externalizable data is written in block data mode and is 
  181.     * terminated with TC_ENDBLOCKDATA. Externalizable classdescriptor
  182.     * flags has SC_BLOCK_DATA enabled. JVM 1.1.6 and greater can 
  183.     * read this format change.
  184.     *
  185.     * Enables writing a nonSerializable class descriptor into the
  186.     * stream. The serialVersionUID of a nonSerializable class is 
  187.     * set to 0L. 
  188.     *
  189.     * @see java.io.ObjectOutputStream#useProtocolVersion(int)
  190.     * @see #SC_BLOCK_DATA
  191.     * @since JDK 1.2
  192.     */
  193.     public final static int PROTOCOL_VERSION_2 = 2;
  194. }
  195.